import React from 'react'

class Handler extends React.Component {
  state = {
    count: 100
  }
  handleClick() {
    console.log(this) // this指向组件实例
    this.setState({
      count: this.state.count - 1
    })
  }
  render() {
    return (
      <div>
        <div>我是类组件</div>
        <p>{this.state.count}</p>
        {/* 使用箭头函数, this指向的是render, render的this指向的是当前组件实例 */}
        <button onClick={() => this.handleClick()}>点击改变状态</button>
      </div>
    )
  }
}

export default Handler